package com.bezdelnick.forum.web.page;

import com.bezdelnick.forum.domain.AppUser;
import com.bezdelnick.forum.service.ForumService;
import com.bezdelnick.forum.web.component.LinkWithText;
import com.bezdelnick.forum.web.page.template.UserMainMenuTemplate;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by IntelliJ IDEA.
 * User: Bezdelnick
 * Date: 23.08.12
 * Time: 0:56
 * To change this template use File | Settings | File Templates.
 */
@AuthorizeInstantiation("ROLE_USER")
public class ShowUserPage extends UserMainMenuTemplate {
    private static final Logger LOGGER = LoggerFactory.getLogger(ShowUserPage.class);

    @SpringBean
    @SuppressWarnings("unused")
    public ForumService forumService;

    private AppUser appUser;

    public ShowUserPage() {
        this(new PageParameters());
    }

    public ShowUserPage(PageParameters parameters) {
        this.getPageParameters().mergeWith(parameters);

        if (!this.getPageParameters().get("id").isNull()) {
            long id = this.getPageParameters().get("id").toLong();
            this.appUser = forumService.getAppUserDao().getUserById(id);
        } else
            appUser = new AppUser();

        Label lblUsername = new Label("username", appUser.getUsername());
        Label lblEmail = new Label("email", appUser.getEmail());

        add(lblUsername);
        add(lblEmail);
    }
}
